Cover TOC Chap Prev Chap Prev Fig Next Fig Next Chap

Chapter 18: Controlling Texture Mapping

../ch18/18fig27.gif
Figure 18.27

An animated, rotating fan texture.

18fig27.wrl
Click on the image to view the VRML scene.

#VRML V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
    children [
    # Rotating fan
        Shape {
            appearance Appearance {
                material Material { }
                texture ImageTexture {
                    url "fan.png"
                    repeatS FALSE
                    repeatT FALSE
                }
                textureTransform DEF FanRotation TextureTransform {
                    center 0.5 0.5
                }
            }
            geometry DEF Square IndexedFaceSet {
                coord Coordinate {
                    point [
                        -1.0 -1.0 -0.1,   1.0 -1.0 -0.1,
                         1.0  1.0 -0.1,  -1.0  1.0 -0.1,
                    ]
                }
                coordIndex [ 0, 1, 2, 3, ]
                texCoord TextureCoordinate {
                    point [
                        0.0 0.0,  1.0 0.0,
                        1.0 1.0,  0.0 1.0,
                    ]
                }
                texCoordIndex [ 0, 1, 2, 3, ]
                solid FALSE
            }
        },
    # Grill in front
        Transform {
            translation 0.0 0.0 0.1
            children Shape {
                appearance Appearance {
                    material Material { }
                    texture ImageTexture {
                        url "grill.png"
                    }
                    textureTransform TextureTransform {
                        rotation 0.785
                        scale 8.0 8.0
                        center 0.5 0.5
                    }
                }
                geometry USE Square
            }
        },
    # Animation clock
        DEF Clock TimeSensor {
            cycleInterval 10.0
            loop TRUE
        },
    # Animation path
        DEF FanPath ScalarInterpolator {
            key      [ 0.0, 0.5,  1.0  ]
            keyValue [ 0.0, 3.14, 6.28 ]
        },
    ]
}
ROUTE Clock.fraction_changed TO FanPath.set_fraction
ROUTE FanPath.value_changed  TO FanRotation.set_rotation